In this set of exercises, we will import some data.
CSV.
readr library and a function that starts with read_...
library(readr)
gpc <-
readr::read_csv("./data/ZA5667_v1-0-0_Stata14_synthetic-data.csv")
##
## -- Column specification --------------------------------------------------------------------------------------------------------------
## cols(
## .default = col_double()
## )
## i Use `spec()` for the full column specifications.
sex to a factor.
col_types argument or after loading them.
gpc <-
readr::read_csv(
"./data/ZA5667_v1-0-0_Stata14_synthetic-data.csv",
col_types = cols(
sex = col_factor()
)
)
haven::write_dta() function.
gpc <-
gpc %>%
haven::write_dta("./MY_CODE/stata_test_file.dta")
haven::write_...() functions.
gpc <-
gpc %>%
haven::write_dta("./MY_CODE/stata_test_file.sav")